﻿<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="{TableName}Form.aspx.cs" Inherits="Sample.{TableName}Form" %>
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title>{TableName:p}</title>
</head>
<body>
    <form id="form1" runat="server">
    <asp:ScriptManager ID="ScriptManager1" runat="server"></asp:ScriptManager>
    <table>
        {TableColumns}{ExcludeColumn:Id}
        <tr>
            <td>{ColumnName:p}</td>
            <td>:</td>
            <td>
                <% if(GetDisplayType == Sample.{TableName}Form.DisplayType.Add) { %>
                {ForeignKeyParent:2,0}
                <% } else { %>
                {ColumnType:1}
                <% } %>
            </td>
        </tr>
        {/TableColumns}{ForeignKeyChilds}
        <tr>
            <td colspan="3">
                <asp:GridView ID="{TableName}LineGrid" runat="server" AutoGenerateColumns="false" 
                    ShowFooter="false" DataKeyNames="Id">
                <Columns>
                    <asp:BoundField DataField="Id" ItemStyle-CssClass="HideElement"
                        HeaderStyle-CssClass="HideElement" FooterStyle-CssClass="HideElement" />
                    <asp:TemplateField>
                        <ItemTemplate><%# Container.DataItemIndex + 1 %></ItemTemplate>
                    </asp:TemplateField>{ForeignKeyChildColumns}{ExcludeColumn:Id, {ForeignKeyChildColumnName}}
                    <asp:TemplateField>
                        <HeaderTemplate>{ColumnName:p}</HeaderTemplate>
                        <EditItemTemplate>
                            {ForeignKeyParent:2,0}
                        </EditItemTemplate>
                        <ItemTemplate>
                            <%# Eval("{ColumnName}") %>
                        </ItemTemplate>
                    </asp:TemplateField>
                    {/ForeignKeyChildColumns}
                </Columns>
                </asp:GridView>
            </td>
        </tr>
        {/ForeignKeyChilds}
        <tr>
            <td colspan="3">
                <asp:Button ID="{TableName}SaveButton" runat="server" Text="Save" OnClick="{TableName}SaveButton_Click" />
                <asp:Button ID="{TableName}CancelButton" runat="server" Text="Cancel" OnClick="{TableName}CancelButton_Click" />
            </td>
        </tr>
    </table>
    </form>
</body>
</html>